********************************************************************************
***
***	File: BlackSuffrage.do
***	Project: Partisan Polarization on Black Suffrage, 1785-1868 
***	Function: Generates Tables and Figures 1,3-4, and 6
*** Author: David A. Bateman
***	Date: February 25, 2019 (This version)
***
********************************************************************************
cd "d:\dab\Dropbox\Documents\CSDP\Black Suffrage"

capture log close
log using "FinalFiles\code\LogBlackSuffrage.log", replace

version 13.1
set more off

********************************************************************************
*** Generate Figure 1: Qualifications for Male Voting, 1780-1920
***
***
*** Figure 1

** Exclude more minor disenfranchisements during first wave of Redemption
use "FinalFiles\data\SuffrageQualifications.dta", clear
replace raceChange = 0 if (year>=1871 & year<=1880 ) 

** Provide indicators for yearly changes
gen state 		= "Delaware" if year==1792
replace state 	= "Kentucky" if year==1799
replace state 	= "Maryland" if year==1801
replace state 	= "Ohio" 	 if year==1803
replace state 	= "New Jersey" if year==1807
replace state 	= "Indiana and Mississippi Territory" if year==1808
replace state 	= "Illinois Territory" if year==1811
replace state 	= "Louisiana" if year==1812
replace state 	= "Missouri Territory" if year==1813
replace state 	= "Connecticut" if year==1814
replace state 	= "Michigan Territory" if year==1819
replace state 	= "New York" if year==1821
replace state 	= "Rhode Island" if year==1822
replace state 	= "Tennessee" if year==1834
replace state 	= "North Carolina" if year==1836
replace state 	= "Pennsylvania" if year==1838
replace state 	= "Rhode Island" if year==1842
replace state 	= "Wisconsin" if year==1866
replace state 	= "Nebraska and Territories" if year==1867
replace state 	= "Reconstruction Constitutions and Iowa" if year==1868
replace state 	= "Reconstruction Constitutions and Minnesota" if year==1869
replace state 	= "15th Amendment" if year==1870
replace state 	= "Florida and Tennessee" if year==1889
replace state 	= "Mississippi" if year==1890
replace state 	= "Louisiana" if year==1894
replace state 	= "South Carolina" if year==1896
replace state 	= "Arkansas" if year==1897
replace state 	= "North Carolina" if year==1900
replace state 	= "Alabama" if year==1901
replace state 	= "Virginia" if year==1902
replace state 	= "Texas" if year==1903
replace state 	= "Georgia" if year==1907
replace state 	= "Oklahoma" if year==1910



*** Make figure of changes along Property and Race dimensions
twoway  (line perEffectiveProperty year, lc(black) lw(medthin) lp(solid ) connect(J)) ///
		(line perWhiteSupremacy year, ///
			connect(J) lc(black) lw(medthin) lp(shortdash) connect(J)) ///
		(scatter perWhiteSupremacy year if raceChange!=0 & (year!=1842 & year!=1866 & year!=1867 & year!=1868 & year!=1869 & year!=1870), ///
			msy(o) mlw(vthin) mcol(white) mlc(black) ///
			lc(black) lw(thin) lp(solid) mlab(state) mlabsize(vsmall) mlabcol(black) mlabpos(4)) ///
		(scatter perWhiteSupremacy year if (year==1842 | year==1866 | year==1867 | year==1868 | year==1869 | year==1870), ///
			msy(o) mlw(vthin) mcol(black) ///
			lc(black) lw(thin) lp(solid) mlab(state) mlabsize(vsmall) mlabcol(black) mlabpos(10)) ///
		, graphregion(color(white)) xtitle("", size(vsmall)) ///
		ytitle("Percent of States and Territories with Qualification", size(small)) ///
		ylab(#10, nogrid angle(h) labsize(vsmall)) ///
		xlab(#20, angle(h) labsize(vsmall)) ///
		yscale(range(0 100) )	xscale(range(`first_year' `last_year') )			///
		title("Figure 1: Qualifications for Male Voting, 1780-1920", ///
			size(small) color(black)) ///
		legend(order(1 2 3 4 5)  col(5)  	///
			label(1 "Property""Qualification") ///
			label(2 "Race""Qualification") ///
			label(3 "Black""Disfranchisement") ///
			label(4 "Black""Re-Enfranchisement") ///
			size(vsmall) keygap(tiny) rowgap(tiny) 	///
			colgap(tiny) symxsize(huge) region(color(none) fcolor(none)))	///
		name(figure1, replace)

graph export "FinalFiles\Figures\Figure1.eps", replace
********************************************************************************
*** Using SuffrageVotes.dta file, generate Tables 1 and 2 and Figures 3-4
***
***
*** Figure 3
use "FinalFiles\data\SuffrageVotes.dta", clear

gen id = _n
reshape long bsuff, i(id) j(new)
drop if bsuff==.


*** Generate five year intervals
gen fiveYr = int(year/5)*5

** Generate Panel (a) of Figure 3
preserve 
	** Separate Democratic-Republicans and Democrats
	replace partyGrp = 9 if partyGrp==1 & year<=1825
	** Do not include Unionists or Third Parties to simplify graph
	drop if partyGrp == 3 | partyGrp==6
	regress bsuff i.fiveYr##i.partyGrp  i.icpsrstate i.new
	levelsof partyC
	margins, over(i.fiveYr i.partyGrp )
	marginsplot, 															///
		recast(line) recastci(rline)										///
		ci1opts(lw(vthin) lc(black) lp(solid))								///
		ci2opts(lw(vthin) lc(black) lp(dash))								///
		ci3opts(lw(vthin) lcol(black) lp(shortdash))						///
		ci4opts(lw(vthin) lcol(black) lp(shortdash_dot))					///
		ci5opts(lw(vthin) lcol(black) lp(solid))							///
		plot1opts(lw(medthick) lc(black) lp(solid))							///
		plot2opts(lw(medthick) lc(black) lp(dash))							///
		plot3opts(lw(medthick) lc(black) lp(shortdash))						///
		plot4opts(lw(medthick) lc(black) lp(shortdash_dot))					///
		plot5opts(lw(medthick) lc(black) lp(solid))							///
		ylabel(,labsize(small) angle(h) nogrid)								///
		xlabel(1785(10)1865, angle(h) labsize(small))						///
		graphregion(col(white)) 											///
		ytitle("Probability of Voting for Black Suffrage", size(small))		///
		xtitle("") title("Support for Black Suffrage by Party", size(small) col(black))	///
		legend(row(2) size(small) region(col(none)) lcol(none)  symxsize(10) ///
			order(6 8 7 9 ) label(6 "Democratic-Republicans/Democrats")  	///
			label(7 "Whigs") label(8 "Federalists") label(9 "Republicans") ) ///
		name(figure3a, replace)
restore
	
** Generate Panel (b) of Figure 3
preserve
	** Separate first- and second-party period
	replace bsuff = 2 if bsuff==0 & year>=1830
	replace bsuff = 3 if bsuff==1 & year>=1830

	qreg ideal i.fiveY##i.bsuff 
	margins, over(i.fiveY i.bsuff)
	marginsplot, recast(line) recastci(rline)								///
		ci1opts(lw(vthin) lc(black) lp(solid))								///
		ci2opts(lw(vthin) lc(black) lp(dash))								///
		ci3opts(lw(vthin) lc(black) lp(solid))								///
		ci4opts(lw(vthin) lc(black) lp(dash))								///
		plot1opts(lw(medthick) lc(black) lp(solid))							///
		plot2opts(lw(medthick) lc(black) lp(dash))							///
		plot3opts(lw(medthick) lc(black) lp(solid))							///
		plot4opts(lw(medthick) lc(black) lp(dash))							///
		ylabel(,labsize(small) angle(h) nogrid)								///
		xlabel(1785(10)1865, angle(h)  labsize(small))						///
		graphregion(col(white)) 											///
		ytitle("Ideological Dimension", size(small))						///
		xtitle("") title("Median Supporter/Opponent Along Ideological Dimension", size(small) col(black))	///
		legend(row(2) size(small) region(col(none)) lcol(none)  symxsize(10) ///
			order(7 8) label(7 "Median Anti-Black Suffrage Legislator") 	///
			label(8 "Median Pro-Black Suffrage Legislator")  )				///
		name(figure3b, replace)
restore

graph combine figure3a figure3b, graphreg(col(white)) imargin(vsmall)  		///
	title("Figure 3: Issue Development on Black Suffrage", size(small) col(black))	///
	note("95% confidence intervals shown. Positive values on ideological dimension associated with Federalists, Whigs, and Republicans; negative values with" "Democratic-Republicans and Democrats.", size(vsmall))
graph export "FinalFiles\Figures\Figure3.eps", replace
********************************************************************************
***
***
*** 
*** Table 1

clear all

use "FinalFiles\data\SuffrageVotes.dta", clear

gen id = _n
reshape long bsuff, i(id) j(new)
drop if bsuff==.

egen group = group(year chamber)
xtset group


***********************************************************************************
eststo drop est*
** Model 1 - 1785-1825 (North)
eststo: xtreg bsuff i.partyGrp##c.perFPOC ideal perEnslaved electionMargin 	///
	if year<=1821 & (south==0 & chamber!="HR" & chamber!="SENATE"), 		///
	fe vce(boot, reps(500) seed(10101))
** Model 2 - 1785-1825 (South & Congress)
eststo: xtreg bsuff i.partyGrp##c.perFPOC ideal perEnslaved electionMargin 	///
	if year<=1821 & (south==1 | chamber=="HR" | chamber=="SENATE"), 		///
	fe vce(boot, reps(500) seed(10101))
** Model 3 - 1830-1840 (South)
eststo: reg bsuff i.partyGrp##c.perFPOC ideal perEnslaved i.icpsrstate 		///
	electionMargin if year>1830 & year<=1840 & south==1, vce(robust)
** Model 4 - 1830-1855 (North)
eststo: xtreg bsuff i.partyGrp##c.perFPOC ideal perLibertyFS electionMargin	///
	if year>1830 & year<=1855, fe vce(boot, reps(500) seed(10101))
** Model 5 - 1830-1855 (North) 
eststo: xtreg bsuff i.partyGrp##c.perFPOC ideal  perLibertyFS electionMargin ///
	perMfg if year>1830 & year<=1855, fe vce(boot, reps(500) seed(10101))
** Model 6 - 1856-1869 (North & Congress)
eststo: xtreg bsuff i.partyGrp##c.perFPOC ideal electionMargin if year>1855	///
	& year<=1870, fe vce(boot, reps(500) seed(10101))

esttab using "FinalFiles\Tables\Table1.rtf", se(2)  drop(1.partyGrp 				///
	1.partyGrp#c.perFPOC 54.icpsrstate 47.icpsrstate) 						///
	order(4.partyGrp 2.partyGrp 3.partyGrp 5.partyGrp 6.partyGrp ideal 		///
	perFPOC  perEnslaved  perLibertyFS perMfg 4.partyGrp#c.perFPOC 			///
	2.partyGrp#c.perFPOC 3.partyGrp#c.perFPOC 5.partyGrp#c.perFPOC 			///
	6.partyGrp#c.perFPOC) label 											///
	title(Predictors of Support for Black Suffrage) 						///
	addnotes("State-Year FE in all but (3) where only two states were included; a state-dummy (not shown) was included.") 	///
	mtitles("1785-1825 (North)" "1785-1825 (South & Congress)" "1830-1840 (South)"	"1830-1855 (North)"	"1830-1855 (North)"	"1856-1869 (North & Congress)") nogaps nodepvars	///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) compress ///
	stats(N r2 chi2, star(chi2) fmt(%9.0g %9.3f)) b(a2) replace
eststo drop est*

********************************************************************************
***
***
*** Table 2 and Figure 4
gen interaction = perEnslaved
label variable interaction "IV"
** Model 1 - Slavery in South
eststo: xtreg bsuff i.partyGrp##c.interaction ideal perFPOC if south==1, 	///
	fe vce(boot, reps(400) seed(10101))
** Panel (a) of Figure 4
margins,  at(interaction = (0 40)) over(i.partyGrp)
marginsplot, 																///
	ci1opts(lw(thin) lc(black) lp(solid))									///
	ci2opts(lw(thin) lc(black) lp(dash))									///
	ci3opts(lw(thin) lc(gs7) lp(shortdash))									///
	plot1opts(col(black) lw(thin) lc(black) lp(solid))						///
	plot2opts(col(white) mlc(black) mlw(thin) lw(thin) lc(black) lp(dash))	///
	plot3opts(col(white) msy(T) mlc(black) mlw(thin) lw(thin) lc(gs7) lp(shortdash))	///
	ylabel(0(.2)1,labsize(small) angle(h) nogrid)							///
	xlabel(, labsize(small))												///
	graphregion(col(white)) 												///
	ytitle("Probability of Voting for Black Suffrage", size(small))			///
	xtitle("Percent of District Held in Slavery", size(small)) 				///
	title("Slavery in Southern States, 1800-1835", size(small) col(black))	///
	legend(pos(6) col(3) size(small) region(col(none)) lcol(none)  symxsize(huge)	///
		order(4 5 6) label(4 "Democrats") label(5 "Whigs") label(6 "Federalists"))	///
	name(figure4a, replace)
** Model 2 - Slavery in North, before 1825
eststo: xtreg bsuff i.partyGrp##c.interaction ideal perFPOC if south==0 & 	///
	year<=1825, fe vce(boot, reps(400) seed(10101))	
** Model 3 - Liberty Party in 1844
replace interaction = perLib1844
eststo: xtreg bsuff i.partyGrp##c.interaction ideal perFPOC perMfg 			///
	if year>1830 & year<=1855, fe vce(boot, reps(400) seed(10101))	
** Model 4 - Free Soil in 1848
replace interaction = perFS1848
eststo: xtreg bsuff i.partyGrp##c.interaction ideal perFPOC perMfg 			///
	if year>1830 & year<=1855, fe vce(boot, reps(400) seed(10101))
** Panel (b) of Figure 4
margins,  at(interaction = (0 25)) over(i.partyGrp)
marginsplot, 			///
	ci1opts(lw(thin) lc(black) lp(solid))									///
	ci2opts(lw(thin) lc(black) lp(dash))									///
	ci3opts(lw(thin) lc(gs7) lp(shortdash))									///
	plot1opts(col(black) lw(thin) lc(black) lp(solid))						///
	plot2opts(col(white) mlc(black) mlw(thin) lw(thin) lc(black) lp(dash))	///
	plot3opts(col(white) msy(T) mlc(black) mlw(thin) lw(thin) lc(gs7) 		///
	lp(shortdash))	ylabel(0(.2)1,labsize(small) angle(h) nogrid)			///
	xlabel(, labsize(small))												///
	graphregion(col(white)) 												///
	ytitle("Probability of Voting for Black Suffrage", size(small))			///
	xtitle("District Vote for Free Soil", size(small)) title("Free Soil", size(small) col(black))	///
	legend(pos(6) col(3) size(small) region(col(none)) lcol(none)  symxsize(huge)	///
		order(4 5 6) label(4 "Democrats") label(5 "Whigs") label(6 "Third Party"))	///
	name(figure4b, replace)
** Model 5 - Manufacturing
replace interaction = perMfg
xtreg bsuff i.partyGrp##c.interaction ideal perFPOC perLibertyFS 			///
	if year>1830 & year<=1870, fe vce(boot, reps(400) seed(10101))
eststo: xtreg bsuff i.partyGrp##c.interaction ideal perFPOC perLibertyFS 	///
	if year>1830 & year<=1870, fe vce(boot, reps(400) seed(10101))
** Make Table 2
esttab using "FinalFiles\Tables\Table2.rtf", se(2)  drop(1.partyGrp 5.partyGrp 6.partyGrp 1.partyGrp#c.interaction) 	///
	order(interaction 4.partyGrp#c.interaction 2.partyGrp#c.interaction 3.partyGrp#c.interaction 				///
		  4.partyGrp 2.partyGrp 3.partyGrp 5.partyGrp 6.partyGrp ideal perFPOC perLibertyFS perMfg )			///
	label title(Predictors of Support for Black Suffrage) addnotes("State-Year FE") 	///
	mtitles("Slavery (South)" "Slavery (North)" "Liberty Party Vote" "Free Soil Vote" "Manufacturing Employment") nogaps nodepvars	///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) compress ///
	stats(N r2 chi2, star(chi2) fmt(%9.0g %9.3f)) b(a2) replace
eststo drop est*

** Make Figure 4
graph combine figure4a figure4b, graphregion(col(white)) imargin(tiny)		///
	title("Figure 4: Marginal Effects of Slavery and Antislavery Vote", color(black) size(small))
graph export "FinalFiles\Figures\Figure4.eps", replace
 
********************************************************************************
*** Using Referenda.dta file, generate Table 4 and Figure 6
***
***
***
use  "FinalFiles\data\Referenda.dta", clear

*** Table 4 -- Uses Won-ho Park, 2008. �Ecological Inference and Aggregate 
*** Analysis of Elections.� Ph.D. Dissertation. University of Michigan.
*** 
*** .ado files included in file upload.   
*** Reports voter transition rates or average voter transition rates when 
*** more than one state is included

*** Elections with Liberty Party candidates
egen group1 = group(year icpsrstate) if (icpsrstate==1 | icpsrstate==13) 	///
	& (year==1846 | year==1847)
avVTR demElection whigElection libElection, second(suffyes suffno suffDrop) group(group1)
matrix Liberty = r(vtr)*100
esttab m(Liberty, fmt(0) transpose) using "FinalFiles\Tables\Table4.rtf", label mlabels(,none) 	///
	refcat(demElection "New York (1846) and Connecticut (1847)", nolabel) 	///
	collabels("For Black Suffrage" "Against Black Suffrage" "Did Not Vote")	replace
*** Elections with Free Soil Candidates
egen group2 = group(year icpsrstate) if fsElection!=.
avVTR demElection whigElection fsElection, second(suffyes suffno suffDrop) group(group2)
matrix freesoil = r(vtr)*100
esttab m(freesoil, fmt(0) transpose) using "FinalFiles\Tables\Table4.rtf", mlabels(,none) 		///
	refcat(demElection "Wisconsin (1847, 1849) and Michigan (1850)", nolabel) ///
	collabels(none)	label append
*** Elections with Abolition Candidates
egen group3 = group(year icpsrstate) if abolElection!=.
avVTR demElection whigElection abolElection, second(suffyes suffno suffDrop) group(group3)
matrix abolition = r(vtr)*100
esttab m(abolition, fmt(0) transpose) using "FinalFiles\Tables\Table4.rtf", mlabels(,none) 		///
	refcat(demElection "New York (1846), Connecticut (1847), Wisconsin (1847, 1849), and Michigan (1850)", nolabel) ///
	collabels(none)	label append
*** Iowa - 1857 
VTR demElection repElection amerElection if icpsrstate==31, second(suffyes suffno suffDrop ) 
matrix Iowa = r(final)*100
matrix Iowa = Iowa[1..3,1..2]
esttab m(Iowa, fmt(0) transpose) using "FinalFiles\Tables\Table4.rtf", mlabels(,none) 			///
	refcat(demElection "Iowa (1857)", nolabel) 								///
	collabels(none)	label append
*** Wisconsin - 1857 
VTR demElection repElection if icpsrstate==25 & year==1857, second(suffyes suffno suffDrop ) 
matrix Wisconsin = r(final)*100
matrix Wisconsin = Wisconsin[1..3,1..2]
esttab m(Wisconsin, fmt(0) transpose) using "FinalFiles\Tables\Table4.rtf", mlabels(,none) 		///
	refcat(demElection "Wisconsin (1857)", nolabel) 						///
	collabels(none)	label append
*** New York - 1860
VTR demElection repElection if icpsrstate==13 & year==1860, second(suffyes suffno suffDrop ) 
matrix NY = r(final)*100
matrix NY = NY[1..3,1..2]
esttab m(NY, fmt(0) transpose) using "FinalFiles\Tables\Table4.rtf", mlabels(,none) 			///
	refcat(demElection "New York (1860)", nolabel) ///
	collabels(none)	label append addnotes("Voter and average transition rates calculated using Won-ho Park (2008)")

*** Figure 6
gen perwhig = whigElection/totElection*100
gen perdem = demElection/totElection*100
gen perfs = fsElection/totElection*100
gen perlib = libElection/totElection*100 
gen pergop = repElection/totElection*100
gen peryes = suffyes/sufftot*100
*** Many of the referenda were held immediately before the Free Soil party.
*** Include the Free Soil results from 1848 for Figure 6 but not ecological 
*** regression.
replace perfs = perFS1848 if perfs==.
*** Figure 6(a)
regress peryes perwhig  [w=sufftot]
loc r2 = round(e(r2), 0.001)
tw 	(scatter peryes perwhig [w=sufftot], msy(oh) mlc(black) mlw(vvthin))	///
	(lfit peryes perwhig, lc(black))	///
	, graphregion(col(white)) ylab(0(20)100, angle(h) labsize(small) nogrid)	///
	xlab(0(20)100, labsize(small)) ytitle("Vote for Black Suffrage", size(small))	///
	xtitle("Party Vote", size(small))	text(90 85 "R-Squared = `r2'", size(small))	///
	legend(col(2) size(small) region(col(none)) lcol(none)  symxsize(medium)	///
		label(1 "District Vote, Weighted by Size") label(2 "Linear Trend"))	///
	name(figure6a, replace)	title("Whig", col(black) size(small))
*** Figure 6(b)
regress peryes perdem  [w=sufftot] if year<1855
loc r2 = round(e(r2), 0.001)
tw 	(scatter peryes perdem [w=sufftot] if year<1855, msy(oh) mlc(black) mlw(vvthin))	///
	(lfit peryes perdem if year<1855, lc(black))	///
	, graphregion(col(white)) ylab(0(20)100, angle(h) labsize(small) nogrid)	///
	xlab(0(20)100, labsize(small)) ytitle("Vote for Black Suffrage", size(small))	///
	xtitle("Party Vote", size(small))	text(90 85 "R-Squared = `r2'", size(small))	///
	legend(col(2) size(small) region(col(none)) lcol(none)  symxsize(medium)	///
			label(1 "District Vote, Weighted by Size") label(2 "Linear Trend"))	///
	name(figure6b, replace)	title("Democratic (pre-1856)", col(black) size(small))		
*** Figure 6(c)			
regress peryes perlib  [w=sufftot]
loc r2 = round(e(r2), 0.001)
tempvar yhat
predict `yhat'
tw 	(scatter peryes perlib [w=sufftot], msy(oh) mlc(black) mlw(vvthin))	///
	(lfit `yhat' perlib if `yhat'<=100, lc(black))	///
	, graphregion(col(white)) ylab(0(20)100, angle(h) labsize(small) nogrid)	///
	xlab(0(20)100, labsize(small)) ytitle("Vote for Black Suffrage", size(small))	///
	xtitle("Party Vote", size(small))	text(90 85 "R-Squared = `r2'", size(small))	///
	legend(col(2) size(small) region(col(none)) lcol(none)  symxsize(medium)	///
			label(1 "District Vote, Weighted by Size") label(2 "Linear Trend"))	///
	name(figure6c, replace)	title("Liberty Party", col(black) size(small))						
*** Figure 6(d)			
regress peryes perfs [w=sufftot]
loc r2 = round(e(r2), 0.001)
tempvar yhat2
predict `yhat2'
tw 	(scatter peryes perfs [w=sufftot], msy(oh) mlc(black) mlw(vvthin))	///
	(lfit `yhat2' perfs if `yhat2'<=100, lc(black))	///
	, graphregion(col(white)) ylab(0(20)100, angle(h) labsize(small) nogrid)	///
	xlab(0(20)100, labsize(small)) ytitle("Vote for Black Suffrage", size(small))	///
	xtitle("Party Vote", size(small))	text(90 90 "R-Squared = `r2'", size(small))	///
	legend(col(2) size(small) region(col(none)) lcol(none)  symxsize(medium)	///
			label(1 "District Vote, Weighted by Size") label(2 "Linear Trend"))	///
	name(figure6d, replace) title("Free Soil Party", col(black) size(small))		
*** Figure 6(e)
regress peryes pergop [w=sufftot]
loc r2 = round(e(r2), 0.001)
tempvar yhat3
predict `yhat3'
tw 	(scatter peryes pergop [w=sufftot], msy(oh) mlc(black) mlw(vvthin))	///
	(lfit `yhat3' pergop if `yhat3'<=100 & `yhat3'>=0, lc(black))	///
	, graphregion(col(white)) ylab(0(20)100, angle(h) labsize(small) nogrid)	///
	xlab(0(20)100, labsize(small)) ytitle("Vote for Black Suffrage", size(small))	///
	xtitle("Party Vote", size(small))	text(90 15 "R-Squared = `r2'", size(small))	///
	legend(col(2) size(small) region(col(none)) lcol(none)  symxsize(medium)	///
			label(1 "District Vote, Weighted by Size") label(2 "Linear Trend"))	///
	name(figure6e, replace)	title("Republican", col(black) size(small))			
*** Figure 6(f)		
regress peryes perdem [w=sufftot] if year>=1856
loc r2 = round(e(r2), 0.001)
tempvar yhat4
predict `yhat4'
tw 	(scatter peryes perdem [w=sufftot] if year>=1856, msy(oh) mlc(black) mlw(vvthin))	///
	(lfit `yhat4' perdem if `yhat4'<=100 & `yhat4'>=0 & year>=1856, lc(black))	///
	, graphregion(col(white)) ylab(0(20)100, angle(h) labsize(small) nogrid)	///
	xlab(0(20)100, labsize(small)) ytitle("Vote for Black Suffrage", size(small))	///
	xtitle("Party Vote", size(small))	text(90 90 "R-Squared = `r2'", size(small))	///
	legend(col(2) size(small) region(col(none)) lcol(none)  symxsize(medium)	///
			label(1 "District Vote, Weighted by Size") label(2 "Linear Trend"))	///
	name(figure6f, replace)	title("Democratic (post-1856)", col(black) size(small))
	
***Figure 6
grc1leg figure6a figure6b figure6c figure6d figure6e figure6f, graphreg(col(white)) imargin(tiny) cols(2)	///
	title("Figure 6: Popular Vote for Black Suffrage, By Party", size(small) color(black))
graph display Graph, xsize(8.5) ysize(11)
graph export "FinalFiles\Figures\Figure6.eps", replace


log close
